package cn.lizemin.threadPool5;

/**
 * @author: lizemin
 * @version: 1.0
 * 这是任务类，需要实现runnable接口
 */
public class MyTask implements Runnable{
    private int id ; // 任务编号

    public MyTask(int id) {
        this.id = id;
    }

    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        System.out.println("线程："+name+"即将执行任务："+id);
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("线程："+name+"完成了任务："+id);

    }

    @Override
    public String toString() {
        return "MyTask{" +
                "id=" + id +
                '}';
    }


}
